﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpObjects.SearchEngine.HtmlParsing.Html
{
    public class HtmlTextInputTag : HtmlTag
    {
        public const string TagName = "input";

        public override string Name { get { return TagName; } set { } }

        public HtmlTextInputTag(HtmlGenericTag tag = null)
            : base(tag)
        {
        }

        public override string Text
        {
            get
            {
                HtmlAttribute valueAttribute = this.GetAttribute("value");
                string text = valueAttribute.Value + " " + base.Text;
                return text;
            }
            set
            {
                base.Text = value;
            }
        }

        public static HtmlTag CreateInstance(HtmlGenericTag tag)
        {
            HtmlAttribute htmlAttribute = tag.GetAttribute("type");

            if (htmlAttribute.Value == "text")
            {
                return new HtmlTextInputTag(tag);
            }
            else
            {
                return tag;
            }
        }

        public override bool IsContent { get { return true; } set { } }
        public override bool HasText { get { return true; } set { } }
    }
}
